﻿<UserControl x:Class="ValidatorDemo.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:slv="clr-namespace:Silverlight.Validators;assembly=Silverlight.Validators"
             xmlns:slvf="clr-namespace:Silverlight.Validators.Filters;assembly=Silverlight.Validators"
    >
    <Grid x:Name="LayoutRoot" Background="White" VerticalAlignment="Top" HorizontalAlignment="Left" >
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="0.248*" />
			<ColumnDefinition Width="150" />
            
			<ColumnDefinition Width="0.362*" />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<slv:ValidatorManager x:Name="Group1"></slv:ValidatorManager>

		<TextBlock Grid.Column="0" Grid.Row="0" Text="Normal:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="1" Text="Required:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="2" Text="Phone:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="2" Text="Required Phone:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="3" Text="SSN:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="4" Text="Numeric Filter:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="5" Text="Range:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="6" Text="Length:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBlock Grid.Column="0" Grid.Row="7" Text="Regex:" VerticalAlignment="Center" HorizontalAlignment="Right" />
		<TextBox x:Name="_Normal" Grid.Column="1" Grid.Row="0" Width="100" HorizontalAlignment="Left"/>
		<TextBox x:Name="_Required" Grid.Column="1" Grid.Row="1" Width="100" HorizontalAlignment="Left">
			<slv:ValidatorService.Validator>
				<slv:RequiredValidator ManagerName="Group1" ErrorMessage="This field is required"/>
			</slv:ValidatorService.Validator>
		</TextBox>
		<TextBox x:Name="_Phone" Grid.Column="1" Grid.Row="2" Width="100" HorizontalAlignment="Left">
			<slv:ValidatorService.Validator>
				<slv:PhoneValidator ManagerName="Group1" ApplyFormat="True" ErrorMessage="Invalid phone number"/>
			</slv:ValidatorService.Validator>
		</TextBox>
		<TextBox x:Name="_RequiredPhone" Grid.Column="1" Grid.Row="2" Width="100" HorizontalAlignment="Left">
			<slv:ValidatorService.Validator>
				<slv:PhoneValidator ManagerName="Group1" IsRequired="True" ApplyFormat="True" ErrorMessage="A valid phone number is required"/>
			</slv:ValidatorService.Validator>
		</TextBox>
		<TextBox x:Name="_SSN" Grid.Column="1" Grid.Row="3" Width="100" HorizontalAlignment="Left">
		<slv:ValidatorService.Validator>
			<slv:SSNValidator ManagerName="Group1" IsRequired="True" ErrorMessage="Invalid SSN"/>
		</slv:ValidatorService.Validator>
		</TextBox>
		<TextBox x:Name="_Numeric" Grid.Column="1" Grid.Row="4" Width="100" slvf:TextBoxFilterService.Filter="Decimal" HorizontalAlignment="Left" />

		<TextBox x:Name="_Range" Grid.Column="1" Grid.Row="5" Width="100" HorizontalAlignment="Left">
		<slv:ValidatorService.Validator>
			<slv:RangeValidator Min="0" Max="1000" ManagerName="Group1" ErrorMessage="Number must be between 0 and 1000"/>
		</slv:ValidatorService.Validator>
		</TextBox>
		<TextBox x:Name="_Length" Grid.Column="1" Grid.Row="6" Width="100" HorizontalAlignment="Left">
			<slv:ValidatorService.Validator>
				<slv:LengthValidator MinLength="0" MaxLength="3" ManagerName="Group1" ErrorMessage="Text can only be up to 3 characters long"/>
			</slv:ValidatorService.Validator>
		</TextBox>
		<TextBox x:Name="_Regex" Grid.Column="1" Grid.Row="7" Width="100" HorizontalAlignment="Left">
			<slv:ValidatorService.Validator>
				<slv:RegexValidator Expression="^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$" ManagerName="Group1" ErrorMessage="Text must be an email address"/>
			</slv:ValidatorService.Validator>
		</TextBox>
		<TextBlock Grid.Column="2" Grid.Row="7"  Text="Expression: ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"/>
		<Button Margin="19,2,42,2" Grid.Column="2" Content="Validate All" x:Name="_ValidateAll" Click="_ValidateAll_Click"/>
	</Grid>
</UserControl>
